//
//  ZYCTeachingAttendanceDetailCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/29.
//

#import "ZYCTeachingAttendanceDetailCell.h"
#import "ZYCTeachingAttendanceDetailModel.h"

@interface ZYCTeachingAttendanceDetailCell ()


@property (nonatomic, strong) UIImageView *annexImageView;
@property (nonatomic, strong) UILabel *annexLabel;
@property (nonatomic, strong) UIButton *downloadButton;

@end
@implementation ZYCTeachingAttendanceDetailCell

- (void)setModel:(ZYCListenClassFilesModel *)model{
    _model = model;
    _annexLabel.text = model.fileName;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.annexImageView];
        [self.contentView addSubview:self.annexLabel];
        [self.contentView addSubview:self.downloadButton];
        
        [self.annexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.top.equalTo(self.contentView).offset(15.0f);
            make.size.mas_equalTo(CGSizeMake(35.0f, 40.0f));
        }];
        [self.annexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.annexImageView.mas_right).offset(6.5f);
            make.right.equalTo(self.downloadButton.mas_left).offset(-6.5f);
            make.centerY.equalTo(self.annexImageView);
        }];
        
        [self.downloadButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-15.0f);
            make.centerY.equalTo(self.annexImageView);
            make.width.mas_equalTo(30.0f).priorityHigh();
        }];

    }
    return self;
}



- (UIImageView *)annexImageView {
    if (!_annexImageView) {
        _annexImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fujian"]];
    }
    return _annexImageView;
}

- (UILabel *)annexLabel {
    if (!_annexLabel) {
        _annexLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 15.0f) titleColor:HEX_RGB(@"#262A28") textAlignment:ZZTextAlignmentLeft];
        _annexLabel.numberOfLines = 0;
    }
    return _annexLabel;
}

- (UIButton *)downloadButton {
    if (!_downloadButton) {
        _downloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _downloadButton.titleLabel.font =  kCustomFont(@"PingFangSC-Regular", 15.0f);
        [_downloadButton setTitleColor:HEX_RGB(@"2079D3") forState:UIControlStateNormal];
        NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"下载" attributes:attribtDic];
        [_downloadButton setAttributedTitle:attribtStr forState:UIControlStateNormal];
        [_downloadButton addTarget:self action:@selector(clickDownloadAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _downloadButton;
}
- (void)clickDownloadAction:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(teachingAttendanceDetailDidDownloadModel:)]) {
        [self.delegate teachingAttendanceDetailDidDownloadModel:self.model];
    }
}

@end
